<?php
/*
	插件概览
*/
defined('BY_JYA') or exit('error');
cfc('core')->checklogin();
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
if($_RQ['op']=='get'){
	$return['set']=$this->plugin_setting('gusetting');
	$this->model('gufee')->update_agent_level($_SESSION['uid']);	
	$return['member']=pdo_get('jy_robshop_member',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
	if(!$return['member']){
		//exi('您还不是会员,请先成为会员','','jy_weishop/member.index/');
	}	
	if($return['member']['ispartner']!=1 || $return['member']['partnerstatus']!=1){
		exi('您还不是股东,请先申请','','/gu.register/');
	}
	if(!$return['member']['realname'] || !$return['member']['mobile']){
		if($return['set']['become_reg']==1){
			exi('请先完善信息','error','jy_robshop/gu.info/');
		}
	}
	$return['member']['nickname']=$_SESSION['member']['nickname'];
	$return['member']['avatar']=$_SESSION['member']['avatar'];
	if($return['member']['partnerlevel']==0){
		$return['member']['levelname']='默认等级';
		$return['member']['bonus']=0;
	}else{
		$return['member']['levelname']=pdo_getcolumn('jy_robshop_gu_level',array('id'=>$return['member']['partnerlevel']),'levelname');
		$return['member']['bonus']=pdo_getcolumn('jy_robshop_gu_level',array('id'=>$return['member']['partnerlevel']),'bonus');
	}
	if($return['set']['zhouqi']!=2){
		$firstday =  strtotime(date("Y-m-01", time()));
		$firstdaystr = date("Y-m-01", time());
		$lastday = strtotime(date('Y-m-d 23:59:59', strtotime("$firstdaystr +1 month -1 day")));
	}else{
		$day=date("d", time());
		if($day<8){
			$firstday =  strtotime(date("Y-m-01", time()));
			$firstdaystr = date("Y-m-01", time());
			$lastday = strtotime(date('Y-m-d 23:59:59', strtotime("$firstdaystr +6 day")));
		}
		if($day>=8 && $day<15){
			$firstday =  strtotime(date("Y-m-08", time()));
			$firstdaystr = date("Y-m-08", time());
			$lastday = strtotime(date('Y-m-d 23:59:59', strtotime("$firstdaystr +6 day")));
		}
		if($day>=15 && $day<22){
			$firstday =  strtotime(date("Y-m-15", time()));
			$firstdaystr = date("Y-m-15", time());
			$lastday = strtotime(date('Y-m-d 23:59:59', strtotime("$firstdaystr +6 day")));
		}
		if($day>=22 ){
			$firstday =  strtotime(date("Y-m-22", time()));
			$firstdaystr = date("Y-m-22", time());
			$lastday = strtotime(date('Y-m-d 23:59:59', strtotime("$firstdaystr +1 month -1 day")));
		}
	}	
	if($return['member']['partnertime']>$firstday){
		$firstday=$return['member']['partnertime'];
	}
	$totalmoney=pdo_getsum('jy_robshop_canlog',array('uniacid'=>$_SESSION['uniacid'],'ispay'=>1,'createtime between'=>array($firstday,$lastday)),'fee');
	if(!$list['money']){
		$list['money']=0;
	}
	if(!$total['money']){
		$total['money']=0;
	}
	$rate=$this->setting['rate']?:10;
	$return['redfee']=intval($totalmoney*$rate)/100;
	$return['bonus_wait']=$return['member']['bonus']?intval($redfee*$return['member']['bonus'])/100:0;
	$return['bonustotal']=pdo_getsum('jy_robshop_gu_billp',array('uniacid'=>$_SESSION['uniacid'],'uid'=>$_SESSION['uid']),'realmoney');
	$return['bonusok']=pdo_getsum('jy_robshop_gu_billp',array('uniacid'=>$_SESSION['uniacid'],'uid'=>$_SESSION['uid'],'status'=>1),'realmoney');
	$return['bonuslock']=price($return['bonustotal']-$return['bonusok']);
	set_html('title',$return['set']['tcenter']?:'股东中心');
	exi($return);
}